package com.smmisia.shop.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

import com.smmisia.shop.constant.TradeOrderEvent;
import com.smmisia.shop.constant.TradeOrderState;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 
 * @TableName trade_order_stream_0000
 */
@TableName(value ="trade_order_stream_0000")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TradeOrderStream implements Serializable {
    /**
     * 主键ID
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 创建时间
     */
    private LocalDateTime gmtCreate;

    /**
     * 修改时间
     */
    private LocalDateTime gmtModified;

    /**
     * 订单号
     */
    private String orderId;

    /**
     * 买家ID
     */
    private String buyerId;

    /**
     * 买家类型
     */
    private String buyerType;

    /**
     * 卖家ID
     */
    private String sellerId;

    /**
     * 卖家类型
     */
    private String sellerType;

    /**
     * 幂等号
     */
    private String identifier;

    /**
     * 商品ID
     */
    private String goodsId;

    /**
     * 商品类型
     */
    private String goodsType;

    /**
     * 商品名称
     */
    private String goodsName;

    /**
     * 商品主图
     */
    private String goodsPicUrl;

    /**
     * 订单金额
     */
    private BigDecimal orderAmount;

    /**
     * 订单状态
     */
    private TradeOrderState orderState;

    /**
     * 已支付金额
     */
    private BigDecimal paidAmount;

    /**
     * 商品单价
     */
    private BigDecimal itemPrice;

    /**
     * 商品数量
     */
    private Integer itemCount;

    /**
     * 支付成功时间
     */
    private LocalDateTime paySucceedTime;

    /**
     * 订单确认时间
     */
    private LocalDateTime orderConfirmedTime;

    /**
     * 完结时间
     */
    private LocalDateTime orderFinishedTime;

    /**
     * 关单时间
     */
    private LocalDateTime orderClosedTime;

    /**
     * 支付方式
     */
    private String payChannel;

    /**
     * 支付流水号
     */
    private String payStreamId;

    /**
     * 关闭类型
     */
    private String closeType;

    /**
     * 逻辑删除标识
     */
    private Integer deleted;

    /**
     * 乐观锁版本号
     */
    private Integer lockVersion;

    /**
     * 幂等号
     */
    private String streamIdentifier;

    /**
     * 流水类型
     */
    private TradeOrderEvent streamType;


    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        TradeOrderStream other = (TradeOrderStream) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getGmtCreate() == null ? other.getGmtCreate() == null : this.getGmtCreate().equals(other.getGmtCreate()))
            && (this.getGmtModified() == null ? other.getGmtModified() == null : this.getGmtModified().equals(other.getGmtModified()))
            && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId()))
            && (this.getBuyerId() == null ? other.getBuyerId() == null : this.getBuyerId().equals(other.getBuyerId()))
            && (this.getBuyerType() == null ? other.getBuyerType() == null : this.getBuyerType().equals(other.getBuyerType()))
            && (this.getSellerId() == null ? other.getSellerId() == null : this.getSellerId().equals(other.getSellerId()))
            && (this.getSellerType() == null ? other.getSellerType() == null : this.getSellerType().equals(other.getSellerType()))
            && (this.getIdentifier() == null ? other.getIdentifier() == null : this.getIdentifier().equals(other.getIdentifier()))
            && (this.getGoodsId() == null ? other.getGoodsId() == null : this.getGoodsId().equals(other.getGoodsId()))
            && (this.getGoodsType() == null ? other.getGoodsType() == null : this.getGoodsType().equals(other.getGoodsType()))
            && (this.getGoodsName() == null ? other.getGoodsName() == null : this.getGoodsName().equals(other.getGoodsName()))
            && (this.getGoodsPicUrl() == null ? other.getGoodsPicUrl() == null : this.getGoodsPicUrl().equals(other.getGoodsPicUrl()))
            && (this.getOrderAmount() == null ? other.getOrderAmount() == null : this.getOrderAmount().equals(other.getOrderAmount()))
            && (this.getOrderState() == null ? other.getOrderState() == null : this.getOrderState().equals(other.getOrderState()))
            && (this.getPaidAmount() == null ? other.getPaidAmount() == null : this.getPaidAmount().equals(other.getPaidAmount()))
            && (this.getItemPrice() == null ? other.getItemPrice() == null : this.getItemPrice().equals(other.getItemPrice()))
            && (this.getItemCount() == null ? other.getItemCount() == null : this.getItemCount().equals(other.getItemCount()))
            && (this.getPaySucceedTime() == null ? other.getPaySucceedTime() == null : this.getPaySucceedTime().equals(other.getPaySucceedTime()))
            && (this.getOrderConfirmedTime() == null ? other.getOrderConfirmedTime() == null : this.getOrderConfirmedTime().equals(other.getOrderConfirmedTime()))
            && (this.getOrderFinishedTime() == null ? other.getOrderFinishedTime() == null : this.getOrderFinishedTime().equals(other.getOrderFinishedTime()))
            && (this.getOrderClosedTime() == null ? other.getOrderClosedTime() == null : this.getOrderClosedTime().equals(other.getOrderClosedTime()))
            && (this.getPayChannel() == null ? other.getPayChannel() == null : this.getPayChannel().equals(other.getPayChannel()))
            && (this.getPayStreamId() == null ? other.getPayStreamId() == null : this.getPayStreamId().equals(other.getPayStreamId()))
            && (this.getCloseType() == null ? other.getCloseType() == null : this.getCloseType().equals(other.getCloseType()))
            && (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()))
            && (this.getLockVersion() == null ? other.getLockVersion() == null : this.getLockVersion().equals(other.getLockVersion()))
            && (this.getStreamIdentifier() == null ? other.getStreamIdentifier() == null : this.getStreamIdentifier().equals(other.getStreamIdentifier()))
            && (this.getStreamType() == null ? other.getStreamType() == null : this.getStreamType().equals(other.getStreamType()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getGmtCreate() == null) ? 0 : getGmtCreate().hashCode());
        result = prime * result + ((getGmtModified() == null) ? 0 : getGmtModified().hashCode());
        result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode());
        result = prime * result + ((getBuyerId() == null) ? 0 : getBuyerId().hashCode());
        result = prime * result + ((getBuyerType() == null) ? 0 : getBuyerType().hashCode());
        result = prime * result + ((getSellerId() == null) ? 0 : getSellerId().hashCode());
        result = prime * result + ((getSellerType() == null) ? 0 : getSellerType().hashCode());
        result = prime * result + ((getIdentifier() == null) ? 0 : getIdentifier().hashCode());
        result = prime * result + ((getGoodsId() == null) ? 0 : getGoodsId().hashCode());
        result = prime * result + ((getGoodsType() == null) ? 0 : getGoodsType().hashCode());
        result = prime * result + ((getGoodsName() == null) ? 0 : getGoodsName().hashCode());
        result = prime * result + ((getGoodsPicUrl() == null) ? 0 : getGoodsPicUrl().hashCode());
        result = prime * result + ((getOrderAmount() == null) ? 0 : getOrderAmount().hashCode());
        result = prime * result + ((getOrderState() == null) ? 0 : getOrderState().hashCode());
        result = prime * result + ((getPaidAmount() == null) ? 0 : getPaidAmount().hashCode());
        result = prime * result + ((getItemPrice() == null) ? 0 : getItemPrice().hashCode());
        result = prime * result + ((getItemCount() == null) ? 0 : getItemCount().hashCode());
        result = prime * result + ((getPaySucceedTime() == null) ? 0 : getPaySucceedTime().hashCode());
        result = prime * result + ((getOrderConfirmedTime() == null) ? 0 : getOrderConfirmedTime().hashCode());
        result = prime * result + ((getOrderFinishedTime() == null) ? 0 : getOrderFinishedTime().hashCode());
        result = prime * result + ((getOrderClosedTime() == null) ? 0 : getOrderClosedTime().hashCode());
        result = prime * result + ((getPayChannel() == null) ? 0 : getPayChannel().hashCode());
        result = prime * result + ((getPayStreamId() == null) ? 0 : getPayStreamId().hashCode());
        result = prime * result + ((getCloseType() == null) ? 0 : getCloseType().hashCode());
        result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
        result = prime * result + ((getLockVersion() == null) ? 0 : getLockVersion().hashCode());
        result = prime * result + ((getStreamIdentifier() == null) ? 0 : getStreamIdentifier().hashCode());
        result = prime * result + ((getStreamType() == null) ? 0 : getStreamType().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", gmtCreate=").append(gmtCreate);
        sb.append(", gmtModified=").append(gmtModified);
        sb.append(", orderId=").append(orderId);
        sb.append(", buyerId=").append(buyerId);
        sb.append(", buyerType=").append(buyerType);
        sb.append(", sellerId=").append(sellerId);
        sb.append(", sellerType=").append(sellerType);
        sb.append(", identifier=").append(identifier);
        sb.append(", goodsId=").append(goodsId);
        sb.append(", goodsType=").append(goodsType);
        sb.append(", goodsName=").append(goodsName);
        sb.append(", goodsPicUrl=").append(goodsPicUrl);
        sb.append(", orderAmount=").append(orderAmount);
        sb.append(", orderState=").append(orderState);
        sb.append(", paidAmount=").append(paidAmount);
        sb.append(", itemPrice=").append(itemPrice);
        sb.append(", itemCount=").append(itemCount);
        sb.append(", paySucceedTime=").append(paySucceedTime);
        sb.append(", orderConfirmedTime=").append(orderConfirmedTime);
        sb.append(", orderFinishedTime=").append(orderFinishedTime);
        sb.append(", orderClosedTime=").append(orderClosedTime);
        sb.append(", payChannel=").append(payChannel);
        sb.append(", payStreamId=").append(payStreamId);
        sb.append(", closeType=").append(closeType);
        sb.append(", deleted=").append(deleted);
        sb.append(", lockVersion=").append(lockVersion);
        sb.append(", streamIdentifier=").append(streamIdentifier);
        sb.append(", streamType=").append(streamType);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }

    public TradeOrderStream(TradeOrder tradeOrder, TradeOrderEvent streamType, String streamIdentifier) {
        this.orderId = tradeOrder.getOrderId();
        this.buyerId = tradeOrder.getBuyerId();
        this.buyerType = tradeOrder.getBuyerType();
        this.sellerId = tradeOrder.getSellerId();
        this.sellerType = tradeOrder.getSellerType();
        this.identifier = tradeOrder.getIdentifier();
        this.orderAmount = tradeOrder.getOrderAmount();
        this.paidAmount = tradeOrder.getPaidAmount();
        this.paySucceedTime = tradeOrder.getPaySucceedTime();
        this.orderConfirmedTime = tradeOrder.getOrderConfirmedTime();
        this.orderFinishedTime = tradeOrder.getOrderFinishedTime();
        this.orderClosedTime = tradeOrder.getOrderClosedTime();
        this.goodsId = tradeOrder.getGoodsId();
        this.goodsType = tradeOrder.getGoodsType();
        this.goodsName = tradeOrder.getGoodsName();
        this.goodsPicUrl = tradeOrder.getGoodsPicUrl();
        this.payChannel = tradeOrder.getPayChannel();
        this.payStreamId = tradeOrder.getPayStreamId();
        this.orderState = tradeOrder.getOrderState();
        this.closeType = tradeOrder.getCloseType();
        this.setLockVersion(tradeOrder.getLockVersion());
        this.setDeleted(tradeOrder.getDeleted());
        this.itemCount = tradeOrder.getItemCount();
        this.itemPrice = tradeOrder.getItemPrice();
        this.streamType = streamType;
        this.streamIdentifier = streamIdentifier;
    }
}